#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/wait.h>

int main()
{
    pid_t id = fork();

    if(id < 0)
    {
        perror("fork fail");
        exit(-1);
    }
    else if(id == 0)
    {
        printf("I am child process\n");
        sleep(5);
        exit(1);
    }
    else
    {
        int status = 0;
        pid_t ret = waitpid(id,&status,0);
        if(ret > 0)
        {
             printf("wait 5s succes, exit code:%d,sig:%d\n",(status>>8)&0xFF,status&0x7F);
            
        }
     }
    return 0;
}
